package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.vo.zbg.AnnualCostDataVo;
import com.ruoyi.system.domain.zbg.AnnualCostData;
import com.ruoyi.system.domain.zbg.AnnualPlanData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface AnnualCostDataMapper extends BaseMapper<AnnualCostData> {

    //获取该市的年度计划
    AnnualPlanData selectByYear(@Param("currentYear") int currentYear);

    //更新或新增年度成本数据

    int insert(@Param("annualCostData") AnnualCostData annualCostData);
    @Insert("<script>" +
            "INSERT INTO annual_cost_data (district, total_repair_quota, repair_line, repair_home, repair_group, repair_power, repair_wireless, repair_maintenance, electric_quota, tower_quota, network_quota, compensation_quota, year) " +
            "VALUES (#{annualCostData.district}, #{annualCostData.totalRepairQuota}, #{annualCostData.repairLine}, #{annualCostData.repairHome}, #{annualCostData.repairGroup}, #{annualCostData.repairPower}, #{annualCostData.repairWireless}, #{annualCostData.repairMaintenance}, #{annualCostData.electricQuota}, #{annualCostData.towerQuota}, #{annualCostData.networkQuota}, #{annualCostData.compensationQuota}, #{annualCostData.year}) " +
            "ON DUPLICATE KEY UPDATE " +
            "total_repair_quota = VALUES(total_repair_quota), " +
            "repair_line = VALUES(repair_line), " +
            "repair_home = VALUES(repair_home), " +
            "repair_group = VALUES(repair_group), " +
            "repair_power = VALUES(repair_power), " +
            "repair_wireless = VALUES(repair_wireless), " +
            "repair_maintenance = VALUES(repair_maintenance), " +
            "electric_quota = VALUES(electric_quota), " +
            "tower_quota = VALUES(tower_quota), " +
            "network_quota = VALUES(network_quota), " +
            "compensation_quota = VALUES(compensation_quota)" +
            "</script>")
    int saveOrUpdate(@Param("annualCostData") AnnualCostData annualCostData);

    List<AnnualCostDataVo> selectYear(@Param("year") int year);

    AnnualCostData selectByYearAndDistrict(@Param("year") Integer year,@Param("district") String district);
}